<?php
// +----------------------------------------------------------------------
// |商品模型
// +----------------------------------------------------------------------
// |Data:2016-06-28 上午10:51
// +----------------------------------------------------------------------
// |Author: 吕志雄 <870923001@qq.com>
// +----------------------------------------------------------------------
namespace Wap\Model;
use Common\Model\CommonModel;

class ProductModel extends CommonModel{
    protected $tableName = 'project';

    /**
     * 获取列表
     * @param array $map
     * @return array
     */
    public function getList($map){
        $list = D('Admin/ProductCate')->getShopCate($map['shop_id']);
        unset($map['shop_id']);
        $map['is_on'] = 1;
        foreach($list as $key=>$val){
            $map['cate_id'] = $val['id'];
            $shopList = $this->where($map)->field('id,cate_id,title,pic,store,is_signature,sales_num,price,unit,attr,chili')->order('is_signature asc,sales_num desc')->select();
            $data[$val['id']] = $shopList;
        }
        return array('cateList'=>$list,'productList'=>$data);
    }

    public function getSearchList($map){
        $shopList = $this->where($map)->field('id,cate_id,title,pic,store,is_signature,sales_num,price,unit,attr,chili')->order('is_signature asc,sales_num desc')->select();
        return $shopList;
    }
}
?>